package GameObjects.Ships.Weapon.ShootingTypes;

import java.util.ArrayList;

import GameObjects.Physics.Position;
import GameObjects.Ships.Weapon.Bullets.Bullet;
import Logic.GameTime;

public abstract class ShootingType 
{
	private GameTime shootTime;
	private boolean canFire = true;
	
	public ShootingType(int delay)
	{
		this.shootTime = new GameTime(delay);
	}
	
	public ArrayList<Bullet> fireWeapon(Position position)
	{
		ArrayList<Bullet> bullets = new ArrayList<Bullet>();
		
		if(canFire)
		{
			bullets = generateBullets(position);
			canFire = false;
		}
		return bullets;
	}
	
	public void tick()
	{
		if(!canFire)
		{
			if(shootTime.hasTickedOver())
				canFire = true;
		}
		else
			shootTime.reset();
	}
	
	protected abstract ArrayList<Bullet> generateBullets(Position position);
}
